package controllers

import (
	m "myerp/models"

	"github.com/astaxie/beego"
)

type IndexController struct {
	CommonController
}

func (this *IndexController) Index() {
	userinfo := this.GetSession("userinfo")
	if userinfo == nil {
		this.Ctx.Redirect(302, beego.AppConfig.String("auth_gateway"))
	}
	//tree := this.GetTree()
	if this.IsAjax() {
		//this.Data["json"] = &tree
		this.ServeJSON()
	} else {
		groups := m.Groups()
		this.Data["userinfo"] = userinfo
		this.Data["groups"] = groups
		//this.Data["tree"] = &tree
		this.Layout = "base.html"
		this.TplName = "index.html"
	}
}
